<?php 
class JobCountTmp extends AppModel{
	var $name = 'JobCountTmp';
	var $useTable = 'job_count_tmp';
	
	
	function getThemaData(){
		$this->query("CALL job_count('tema_id')");
		$sql = "SELECT" .
				 " JobCountTmp.today_count," .
				 " JobCountTmp.all_count," .
				 " SysParamsThema.name" .
			   " FROM job_count_tmp AS JobCountTmp" .
			   " LEFT JOIN sys_params_mst AS SysParamsThema" .
			     " ON JobCountTmp.id = SysParamsThema.id and" .
			     " SysParamsThema.deleted IS NULL AND SysParamsThema.kbn='tema_id'" .
			   " WHERE JobCountTmp.kbn='tema_id'" .
			   " ORDER BY JobCountTmp.id" ;
			   
		$data = $this->query($sql);
		return $data;
	}
	
	function getAreaData(){
		$this->query("CALL job_count('area_id')");
		$sql = "SELECT" .
				 " JobCountTmp.today_count," .
				 " JobCountTmp.all_count," .
				 " SysParamsArea.name" .
			   " FROM job_count_tmp AS JobCountTmp" .
			   " LEFT JOIN sys_params_mst AS SysParamsArea" .
			     " ON JobCountTmp.id = SysParamsArea.id and" .
			     " SysParamsArea.deleted IS NULL AND SysParamsArea.kbn='area_id'" .
			   " WHERE JobCountTmp.kbn='area_id'" .
			   " ORDER BY JobCountTmp.id" ;
			   
		$data = $this->query($sql);
		return $data;
	}
} 
?>